public class Solution {
    public int firstUniqueChar(String s) {
        int[] count = new int[26];
        char[] S = s.toCharArray();
        for (int i = 0; i < s.length(); i++) {
            int a = S[i] - 'a';
            count[a]++;
        }
        for (int i = 0; i < s.length(); i++) {
            int a =  S[i] - 'a';
            if (count[a] == 1) {
                return i;
            }
        }
        return -1;
    }
}
